package com.zking.service.dwm;

import com.zking.entity.User;
import com.zking.mapper.UserMapper;
import com.zking.utils.EncryptUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class UserService_dwm {

    @Autowired
    private UserMapper userMapper;


    public User queryUser(String name){
        return userMapper.queryUser(name);
    }


    public User queryByname(String username){
        return userMapper.queryByname(username);

    }

    //注册
    public  int register(String username,String password,String phone){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        String created = df.format(new Date());// new Date()为获取当前系统时间
        String password2 = EncryptUtils.getEncryptStr(password);//密码加密
        System.out.println(username+"  "+password2+"  "+phone+"  "+created);
        return userMapper.register(username,password2,phone,created);
    }
}
